package com.htgraph.flash;

import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxIGraphModel;
import com.mxgraph.util.mxUtils;
import com.mxgraph.util.mxConstants;

import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2010-11-25
 */
public class FontFlasher extends Flasher {

    //String styleName = mxConstants.STYLE_FILLCOLOR;
    String styleName = mxConstants.STYLE_FONTCOLOR;

    public FontFlasher(mxIGraphModel model, String styleName) {
        super(model);
        this.styleName = styleName;
    }

    public FontFlasher() {
    }

    public FontFlasher(String styleName) {
        this.styleName = styleName;
    }

    public FontFlasher(mxIGraphModel model) {
        super(model);
    }

    public void doFlash() {
        if (!newState) {
            for (mxCell cell : toFlashCells) {
                String style = originalStyle.get(cell);
                if (style == null)
                    continue;
                model.setStyle(cell, style);
            }
        } else {
            for (mxCell cell : toFlashCells) {
                //String style = mxUtils.setStyle(model.getStyle(cell), styleName, mxUtils.hexString(Color.GRAY));
                String style = mxUtils.setStyle(model.getStyle(cell), styleName, mxUtils.hexString(Color.black));
                model.setStyle(cell, style);
            }
        }
    }

    public String getStyleName() {
        return styleName;
    }

    public void setStyleName(String styleName) {
        this.styleName = styleName;
    }
}